﻿<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true"
	CodeFile="SectionBalance.aspx.cs" Inherits="Pages_SectionBalance" Title="Raport Balanta" %>

<%@ MasterType VirtualPath="~/MasterPage.master" %>
<%@ Register Namespace="NS_Controls" TagPrefix="cc1" %>
<%@ Register Namespace="CustomControlsNS" TagPrefix="cc2" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolderContent" runat="Server">
	<asp:UpdatePanel ID="up1" runat="server">
		<ContentTemplate>
			<!-- HTML title: "HIPOCRATE - Raport de venituri si cheltuieli rulat pe sectii" -->
			<!-- page title: "Pregatire rulare raport de venituri si cheltuieli rulat pe sectii" -->
			<h3 class="menu_th">
				Pregatire imprimare raport de venituri si cheltuieli rulat pe sectii
			</h3>
			<table id="timeFrame" border="0" width="75%" style="margin: auto">
				<tr class="tdn">
					<td width="15%" align="right">
						<asp:Label runat="server" ID="lblStart" Style="font-weight:bold" Text="De la" />:
						&nbsp;
					</td>
					<td width="35%" align="center">
						<asp:TextBox ID="strSD" runat="server" MaxLength="10" Width="90px" BorderStyle="Groove" />
						<ajaxToolKit:FilteredTextBoxExtender ID="FilteredTextBoxExtenderStart" runat="server"
							TargetControlID="strSD" ValidChars=".-/0123456789" />
						<ajaxToolKit:CalendarExtender ID="CalendarExtenderStart" runat="server" TargetControlID="strSD"
							PopupButtonID="imgCalStart" />
						<asp:TextBox ID="strSH" runat="server" MaxLength="5" Width="40px" /> <!-- size="5" -->
						*
					</td>
					<td width="15%" align="right">
						<asp:Label runat="server" ID="lblEnd" Style="font-weight:bold" Text="Pana la" />:
						&nbsp;
					</td>
					<td width="35%" align="center">
						<asp:TextBox ID="strED" runat="server" MaxLength="10" Width="90px" BorderStyle="Groove" />
						<ajaxToolKit:FilteredTextBoxExtender ID="FilteredTextBoxExtenderEnd" runat="server"
							TargetControlID="strED" ValidChars=".-/0123456789" />
						<ajaxToolKit:CalendarExtender ID="CalendarExtenderEnd" runat="server" TargetControlID="strED"
							PopupButtonID="imgCalEnd" />
						<asp:TextBox ID="strEH" runat="server" MaxLength="5" Width="40px" /> <!-- size="5" -->
						*
					</td>
				</tr>
				<tr class="tdn">
					<td align="right">
						<asp:Label runat="server" ID="lblSection" Style="font-weight:bold" Text="Sectia" />:
						&nbsp;
					</td>
					<td colspan="3">
						<asp:DropDownList ID="strSection" runat="server" CssClass="box"
							DataValueField="Code" DataTextField="Name" />
						*
					</td>
				</tr>
				<tr>
					<td colspan="4" align="center">
						<cc2:CustomButton ID="viewBalanta" runat="server" Text="Raport"
							OnClick="showReport();" OnServerClick="viewBalanta_Click" />
					</td>
				</tr>
			</table>
		</ContentTemplate>
	</asp:UpdatePanel>

	<script src="<% =ResolveClientUrl("~/Scripts/validate.js") %>" type="text/javascript"></script>
	<script language="javascript" type="text/javascript">

		var g_str_strSection = '<% =strSection.ClientID %>';
		var g_str_strSD = '<% =strSD.ClientID %>';
		var g_str_strSH = '<% =strSH.ClientID %>';
		var g_str_strED = '<% =strED.ClientID %>';
		var g_str_strEH = '<% =strEH.ClientID %>';

		function showReport() {
			if (!validate())
				return;

			section = $get(g_str_strSection).options[$get(g_str_strSection).selectedIndex].value;
			strSD = $get(g_str_strSD).value;
			strSH = $get(g_str_strSH).value;
			strED = $get(g_str_strED).value;
			strEH = $get(g_str_strEH).value;

			var aURL = 'SectionBalanceReport.aspx?Section=' + section + '&SDT=' + strSD + '+' + strSH + '&EDT=' + strED + '+' + strEH;
			var sOptions = 'toolbar=0,location=1,status=1,menubar=0,scrollbars=1,resizable=1';
			sOptions = sOptions + ',width=' + (screen.availWidth - 10).toString();
			sOptions = sOptions + ',height=' + (screen.availHeight - 152).toString();
			sOptions = sOptions + ',screenX=0,screenY=0,left=0,top=0';
			var winName = '_blank';
			var wOpen = window.open('', winName, sOptions);
			wOpen.location = aURL;
		}

		function isDate(value) {
			if (isNaN(new Date(value).getFullYear()))
				return (!isNaN(new Date(value.toString().replace(".", "/").replace(".", "/")).getFullYear()));
			return true;
		}

		function validate() {
			if (!isDate($get(g_str_strSD).value)) {
				alert("Data de inceput nu este valida.\nFormatul corect este zz/ll/aaaa.");
				$get(g_str_strSD).focus();
				return false;
			}

			if (!isTime($get(g_str_strSH).value)) {
				alert("Ora de inceput nu este valida.\nFormatul corect este hh:mm.");
				$get(g_str_strSH).focus();
				return false;
			}

			if (!isDate($get(g_str_strED).value)) {
				alert("Data de inceput nu este valida.\nFormatul corect este zz/ll/aaaa.");
				$get(g_str_strED).focus();
				return false;
			}

			if (!isTime($get(g_str_strEH).value)) {
				alert("Ora de inceput nu este valida.\nFormatul corect este hh:mm.");
				$get(g_str_strEH).focus();
				return false;
			}

			return true;
		}
	</script>

</asp:Content>
